class PointController < ApplicationController
  def new
    @point = Point.new
  end
  def create
    if current_user
      @coord=Coord.new
      #Добавим координату
      @coord=Coord.create(:x => params[:coord][:x], :y => params[:coord][:y])
      last_coord_id=Coord.last.id
      #Добавим остановку
      @point=Point.create(:name => params[:point][:name], :description => params[:point][:description], :street_id=>params[:point][:street_id])
      last_point_id=Point.last.id
      @point_coord=PointCoord.new
      #Добавим связь
      @point_coord=PointCoord.create(:coord_id=>last_coord_id,:point_id=>last_point_id)
      redirect_to :action => "show", :id => last_point_id
    else
      redirect_to(:action =>'index')
    end
  end
  def show
    @content=Point.find(params[:id])
  end
  def index
    @content=Point.all
  end
end